package com.xbongbong.saas.domain.entity;/*/*/

import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.paas.toolbox.wrap.Entity;
import com.xbongbong.pro.constant.I18nStringConstant;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.context.i18n.LocaleContextHolder;

import java.util.Locale;
import java.util.Objects;

/**
 * 工单模板分类entity
 * @author 魏荣杰
 * @date 2019/3/5 11:09
 * @since v1.0
 * @version v1.0
 */
@Setter
@Getter
@ToString
public class WorkOrderTemplateCategoryEntity extends Entity{
    private static final long serialVersionUID = 6553172253983991288L;
    /**
     * 主键
     */
    private Long id;
    /**
     * 公司id
     */
    private String corpid;
    /**
     * 应用id
     */
    private Long appId;
    /**
     * 模板分类名
     */
    private String name;
    /**
     * 模板分类英文名
     */
    private String nameEn;
    /**
     * 是否为默认，1为默认分类，0不是默认分类
     */
    private Integer isDefault;
    /**
     * 排序值
     */
    private Integer sort;
    /**
     * 创建人ID
     */
    private String creatorId;
    /**
     * 创建人姓名
     */
    private String creatorName;
    /**
     * 最近修改人ID
     */
    private String modifierId;
    /**
     * 最近修改人姓名
     */
    private String modifierName;
    /**
     * 增加时间
     */
    private Long addTime;
    /**
     * 更新时间
     */
    private Long updateTime;
    /**
     * 删除标记 0未删除，1删除
     */
    private Integer del;

    /**
     * 镜像工单分类id(镜像应用复制时使用)
     */
    private Long mirrorCategoryId;

    public WorkOrderTemplateCategoryEntity() {
    }

    public WorkOrderTemplateCategoryEntity(String corpid, Long appId, String name, Integer isDefault, Integer sort, String creatorId, String creatorName, String modifierId, String modifierName, Long addTime, Long updateTime, Integer del) {
        this.corpid = corpid;
        this.appId = appId;
        this.name = name;
        this.isDefault = isDefault;
        this.sort = sort;
        this.creatorId = creatorId;
        this.creatorName = creatorName;
        this.modifierId = modifierId;
        this.modifierName = modifierName;
        this.addTime = addTime;
        this.updateTime = updateTime;
        this.del = del;
    }

    public String getName() {
        Locale locale = LocaleContextHolder.getLocale();
        if (Objects.equals(locale.getLanguage(), I18nStringConstant.ENGLISH_LANGUAGE)&& StringUtil.isNotEmpty(nameEn)) {
            return nameEn;
        }
        return name;
    }

    public String getNameEn() {
        Locale locale = LocaleContextHolder.getLocale();
        if (Objects.equals(locale.getLanguage(), I18nStringConstant.ENGLISH_LANGUAGE)) {
            return name;
        }
        return nameEn;
    }
}
